Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use concepts more #5537

Merged
merged 3 commits into from
Oct 8, 2024

Conversation

scarf005
Copy link
Member

@scarf005 scarf005 commented Oct 8, 2024

Checklist

Required

Purpose of change

followup to #5514; concept is easier to understand than SNIFAE, let's use them more!

Describe the solution

check individual commits for details.

Describe alternatives you've considered

use less overloading trickery and just use different name for optional?

Testing

compiled in my machine (tm) but need to check if the concepts translation is correct because they're done 100% manually

Additional context

i'm dumdum and found this after i've done it manually: https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-constraints.html

@github-actions github-actions bot added the src changes related to source code. label Oct 8, 2024
@OrenAudeles
Copy link
Collaborator

Windows build looks like it's failing to import vcpkg
Android build is choking in

generic_factory.h:805:8: error: expected concept name with optional arguments
      -> std::same_as<bool>;

@scarf005
Copy link
Member Author

scarf005 commented Oct 8, 2024

@scarf005
Copy link
Member Author

scarf005 commented Oct 8, 2024

@OrenAudeles fixed in c3f5c00 (#5537)

@OrenAudeles
Copy link
Collaborator

nice, android build succeeded and since Windows build hasn't died from vcpkg it'll probably be okay. Once all of the builds finish it's probably okay to call it ready. TBH I'm not familiar enough with concepts nor requires to do a good job of reviewing this one.

OrenAudeles
OrenAudeles previously approved these changes Oct 8, 2024
Copy link
Collaborator

@OrenAudeles OrenAudeles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to be building fine, and only have the one question below because I'm not familiar with how JSON loading templatey stuff works other than "it just works"(tm).

template < typename MemberType, typename ReaderType, typename DefaultType = MemberType,
typename = typename std::enable_if <
!std::is_constructible<MemberType, const ReaderType &>::value >::type >
template<typename MemberType, typename ReaderType> requires SupportsReader<MemberType, ReaderType>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the requires SupportsReader<...> here negate the requirement for the enable_if<is_constructible<...>> in the earlier default value optional implementation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err wait no i don't think so, lemme write a fix real quick

Copy link
Member Author

@scarf005 scarf005 Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in a23cd22 (#5537), this one can be trusted because it's auto-migrated with clang-tidy. also #5540 because std::same_as is removed, preventing this error from happening

Copy link
Collaborator

@OrenAudeles OrenAudeles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@OrenAudeles OrenAudeles merged commit 1510f81 into cataclysmbnteam:main Oct 8, 2024
11 checks passed
@scarf005 scarf005 deleted the refactor/use-concepts branch October 9, 2024 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants